import { fromJS } from "immutable";
import * as actionTypes from './actionTypes'

const defaultState = fromJS({
    articleList:[],
    recommendList:[],
    articlePage:1,
    showScroll:false
})

export default (state = defaultState,action)=>{
    switch(action.type){
        case actionTypes.CHANGE_HOME_PAGE:
            return state.merge({
                'articleList':fromJS(action.articleList),
                'recommendList':fromJS(action.recommendList) 
            });
        case actionTypes.ADD_HOME_LIST:
            return state.merge({
                'articleList':state.get('articleList').concat(action.list),
                'articlePage':action.nextPage
            })
        case actionTypes.TOGGLE_SCROLL_SHOW:
            return state.set('showScroll',action.show)
            
        default:
            return state
    }      
}